package com.zhilun.check.entity;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.Objects;

@Data
public class ZhiLunSensorDataParam implements Serializable {

    @ExcelProperty("传感器号")
    private String sensorId;
    @ExcelProperty("安装时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date date;
    
    @ExcelProperty("车牌")
    private String licensePlate;

    @ExcelProperty("id")
    private Integer id;


    @ExcelProperty("轮位")
    private String location;


    @ExcelProperty("终端号")
    private String deviceId;

    @ExcelProperty("来源")
    private String source ="知轮";


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ZhiLunSensorDataParam)) return false;
        ZhiLunSensorDataParam that = (ZhiLunSensorDataParam) o;
        return Objects.equals(sensorId, that.sensorId) && Objects.equals(licensePlate, that.licensePlate) && Objects.equals(location, that.location) && Objects.equals(deviceId, that.deviceId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sensorId, licensePlate, location, deviceId);
    }

    public static void main(String[] args) {
        System.out.println(getUsernameFromOperator("36771776||guofeng1||郭风"));
    }

    private static  String getUsernameFromOperator(String operator) {
        return Convert.toStr(CollUtil.getLast(Arrays.asList(operator.split("\\|\\|"))));
    }
}
